using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MeetingRoom.Domain;
using MeetingRoom.Web.View;
using MeetingRoom.Web.Presenter;

public partial class View_ApplyControl : System.Web.UI.UserControl, IApplyView
{
    protected ApplyPresenter presenter = null;

    protected Schedule schedule = null;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Submit_Click(object sender, EventArgs e)
    {
        this.schedule = new Schedule();
        this.schedule.Name = this.TextBoxName.Text;

        DateTime selectedDate = this.CalendarDate.SelectedDate;
        int hour = Int32.Parse(this.TextHour.Text);
        int minute = Int32.Parse(this.TextMinute.Text);

        this.schedule.Duration = new Duration(
            new DateTime(
            selectedDate.Year,
            selectedDate.Month,
            selectedDate.Day,
            hour,
            minute,
            0),
            new DateTime(
            selectedDate.Year,
            selectedDate.Month,
            selectedDate.Day,
            hour,
            minute,
            0)
        );
        MeetingRoom.Domain.MeetingRoomType meetingRoomType = new MeetingRoomType();
        meetingRoomType.Size = Int32.Parse(
            this.DropDownListAvailableRoomSize.SelectedValue);
        meetingRoomType.Projector = Boolean.Parse(
            this.DropDownListProjector.SelectedValue);

        this.schedule.MeetingRoomType = meetingRoomType;

        this.presenter.Apply();
    }

    #region IApplyView Members

    public ApplyPresenter Presenter
    {
        set
        {
            this.presenter = value;
        }
    }

    public Schedule Schedule
    {
        get { return this.schedule; }
    }

    public string Message
    {
        set
        {
            this.LabelMessage.Visible = true;
            this.LabelMessage.Text = value;
        }
    }

    #endregion
}
